home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 5
/
Amiga Tools 5.iso
/
tools
/
datatypes
/
fpwav
/
source
/
fastconvert.asm
< prev
next >
Wrap
Assembly Source File
|
1995-01-20
|
3KB
|
130 lines
******************************************************************************
*
* WAV Datatype, based on the sourcecode found in OS3.1 Native Developer Kit
*
* Written by David N.Junod and Christian Buchner
*
******************************************************************************
* fastconvert.asm
SECTION Code
; 8 bit unsigned MONO -> 8 bit signed MONO conversion
; ===================================================
; a0=source
; a1=destination
; d0=destlength
;
XDEF _ConvertMono8
_ConvertMono8 move.l d2,-(sp) ; save registers
move.l #$80808080,d2 ; keep EOR value in d2 (faster)
move.l d0,-(sp) ; save len for later use
; loop for len/4
lsr.l #2,d0 ; divide length by 4
bra.s loopentrym8 ; enter loop
outerloopm8 swap d0
innerloopm8 move.l (a0)+,d1 ; get LONGWORD
eor.l d2,d1 ; convert sign bits
move.l d1,(a1)+ ; put LONGWORD
loopentrym8 dbra d0,innerloopm8 ; loop length
swap d0
dbra d0,outerloopm8
; loop for len MOD 4
move.l (sp)+,d0 ; get len from stack
and.l #3,d0 ; calc len MOD 4
bra.s restentrym8 ; enter loop
restloopm8 move.b (a0)+,d1 ; get BYTE
eor.b d2,d1 ; convert sign bit
move.b d1,(a1)+ ; put BYTE
restentrym8 dbra d0,restloopm8
move.l (sp)+,d2 ; restore registers
rts
; 8 bit unsigned STEREO -> 8 bit signed MONO conversion
; =====================================================
XDEF _ConvertStereo8
_ConvertStereo8 move.l d2,-(sp) ; save registers
bra.s loopentrys8 ; enter loop
outerloops8 swap d0
innerloops8 move.b (a0)+,d1 ; get LEFT UBYTE
lsr.b #1,d1 ; halve falue
move.b (a0)+,d2 ; get RIGHT UBYTE
lsr.b #1,d2 ; halve value
add.b d2,d1 ; sum up values
eor.b #$80,d1 ; convert sign bit
move.b d1,(a1)+ ; put BYTE
loopentrys8 dbra d0,innerloops8 ; loop length
swap d0
dbra d0,outerloops8
move.l (sp)+,d2 ; restore registers
rts
; 16 bit unsigned MONO -> 8 bit signed MONO conversion
; ====================================================
XDEF _ConvertMono16
_ConvertMono16 bra.s loopentrym16 ; enter loop
outerloopm16 swap d0
innerloopm16 move.w (a0)+,d1 ; get WORD
move.b d1,(a1)+ ; put BYTE
loopentrym16 dbra d0,innerloopm16 ; loop length
swap d0
dbra d0,outerloopm16
rts
; 16 bit unsigned STEREO -> 8 bit signed MONO conversion
; ======================================================
XDEF _ConvertStereo16
_ConvertStereo16
move.l d2,-(sp) ; save registers
bra.s loopentrys16 ; enter loop
outerloops16 swap d0
innerloops16 move.w (a0)+,d1 ; get left WORD
move.w (a0)+,d2 ; get right WORD
asr.b #1,d1 ; halve MSB values
asr.b #1,d2 ; (Intel format -> LowBytes!)
add.b d2,d1 ; sum up values
move.b d1,(a1)+ ; put BYTE
loopentrys16 dbra d0,innerloops16 ; loop length
swap d0
dbra d0,outerloops16
move.l (sp)+,d2 ; restore registers
rts
END